<html>
<head>
<title>ThinMVC Documentation: Controller</title>
</head>
<body>
<h3>ThinMVC Documentation: The ThinMVC_Controller Class</h3>

      <p>The MVC_Controller class is the superclass for all controllers.</p>
      <h3>Methods</h3>
      <p><em>view( [ $file ] )</em> - Returns the path to include for the given view.</p>
<blockquote>
<p> This is usually used at the end of a controller subroutine to generate the view, like this: <i>include( $this->view() )</i> or <i>include( $this->view("menu") )</i></p>
<p>$file isn't necessary&mdash;by default it will return the view file that goes along with the current request. Example: http://site.com/user/report would return the path to "report.php" by default.</p><p>The view routine will check through the $config['viewchain'] array to find the proper view, starting at index 0 and moving up. It will fall back as well, so if your chain were <i>array("iphone","mobile","pages")</i> it would first check the "iphone" folder, then "mobile", then "pages".</p>
<p>If no appropriate "view" is found, the system will run <i>default_method()</i> if your controller has one.</p>
<p> The default folder for views is "pages".</p>
</blockquote>
      <p><em>callNext()</em> - Call the next method or page in the chain.</p>
      <p><em>redirect( $url )</em> - Redirect the request to a new URL</p>
      <p><em>_init( )</em> - Does nothing by default but can be overridden to run just after object instantiation.</p>
      <h3>Magic Functions for Your Controllers</h3>
      <p>These methods don't exist in MVC_Controller, but you can use them in
        your controllers as needed:</p>
      <p><em>always() </em>- If you have an <em>always()</em> method, it will
        always be run before any other methods (so that you can check
        for permissions, wrap the page in a template, etc). As always, the method
        will need to contain a <em>$this-&gt;callNext()</em> call if you want
        execution to continue to other methods, controllers, etc.</p>
      <p><em>default_method()</em> - If there is no method or page that matches
        the path, or if there is no view that matches a call to <i>view()</i>, <em>default_method()</em> will be run instead.</p>
      <h3>Variables</h3>
      <p><em>$this-&gt;config</em> - the configuration array</p>
      <p><em>$this-&gt;dbh</em> - the database handle (if you are using one)</p>
      <p><em>$this-&gt;object</em> - the object for this folder (if there is one).
        For example, if the controller running is &quot;/user/userController.php&quot;,
        and a &quot;user/user.php&quot; file exists, <em>$this-&gt;object</em>
        is an instance of the object in "user.php".</p>
      <p><em>$this-&gt;info</em> - this array contains information pertinent to the current request, including:</p>
      <ul>
      <li> <em>requestpath</em> - the entire path for this reques, including directories above and below the current controller or view (example: "phpmvc/mvccontroller")</li>
      <li> <em>atPath</em> - the current path that is being run (example: "user")</li>
      <li> <em>subPath</em> - the next step in the path chain.</li>
      <li> <em>nextSteps</em> - an array containing the next directories to look in (below the one currently being run)</li>
      </ul>


</body>
</html>
